package managers
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import mx.collections.ArrayCollection;
	
	public class URLManager extends EventDispatcher
	{
		private static const LIST_CHANGED:String = "URLManagerListChanged";
		private var _feedList:ArrayCollection = new ArrayCollection();
		private var dispatcher:IEventDispatcher;
		
		[Bindable(event=LIST_CHANGED)]
		public function get feedList():ArrayCollection
		{
			return _feedList;
		}
		
		public function URLManager(target:IEventDispatcher)
		{
			dispatcher = target;
			super(target);
		}
		
		public function addURL(URL:String):void
		{
			_feedList.addItem(URL);
			dispatchEvent(new Event(LIST_CHANGED));
		}
		
		public function removeURL(URL:String):void
		{
			var targetIndex:int = _feedList.getItemIndex(URL);
			if (targetIndex < 0)
			{
				/* Optionally dispatch an error event here */
				return;
			}
			_feedList.removeItemAt(targetIndex);
			dispatchEvent(new Event(LIST_CHANGED));
		}
	}
}